package com.lsb.blog.controller;


import com.lsb.blog.response.Result;
import com.lsb.blog.service.CommentService;
import com.lsb.blog.vo.CommentVo;
import com.lsb.blog.vo.params.CommentParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author liusibo
 * @since 2021-08-05
 */
@RestController
@RequestMapping("/comments")
public class CommentController {

    @Autowired
    private CommentService commentService;

    //查询文章所有评论
    @GetMapping("/article/{id}")
    public Result comments(@PathVariable("id") Long articleId){
        List<CommentVo> commentVoList = commentService.commentsByArticleId(articleId);
        return Result.ok().data(commentVoList);

    }

    @PostMapping("/create/change")
    public Result comment(@RequestBody CommentParam commentParam){
        return commentService.comment(commentParam);
    }
}

